import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/main/task/models/cell.dart';
import 'package:leader_help/page/task/main/task/models/cell_item.dart';

import 'package:leader_help/utils/util.dart';

class IndustryCell1 extends StatelessWidget {
  const IndustryCell1({Key? key, required this.mod}) : super(key: key);
  final IndustryCellModel mod;
  @override
  Widget build(BuildContext context) {
    var _list = [
      Container(
        constraints: BoxConstraints(minHeight: 50.r),
        padding: EdgeInsets.symmetric(vertical: 5.r),
        child: Row(
          children: [
            loadImage(
                url: 'icon_distribute.png'.imgPathTask,
                width: 30.r,
                height: 30.r),
            Flexible(
                child: Text(
              mod.title,
              style: pfMediumStyle(color: ColorsUtil.red, fontSize: 13.sp),
            ))
          ],
        ),
      ),
      loadImage(
        url: mod.pic,
        width: Get.width,
        fit: BoxFit.fitWidth,
      ),
    ];
    var _items = mod.list.map(
      (e) => getIndustryItemWidget(
        mod: e,
      ),
    );
    _list.addAll(_items);
    return Container(
      child: Column(
        children: _list,
      ),
    );
  }
}

Widget getIndustryItemWidget({
  required IndustryCellItemModel mod,
}) {
  return Container(
    alignment: Alignment.center,
    height: 40.r,
    margin: EdgeInsets.symmetric(horizontal: 30.r),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Container(
          width: 8.r,
          height: 8.r,
          decoration: BoxDecoration(
            color: mod.activeColor,
            borderRadius: BorderRadius.circular(4.r),
          ),
        ),
        Container(
          padding: EdgeInsets.symmetric(horizontal: 8.r),
          margin: EdgeInsets.only(right: 20.r),
          width: 120.r,
          decoration: const BoxDecoration(
              border: Border(
            right: BorderSide(color: ColorsUtil.separator, width: 0.5),
          )),
          child: Text(
            mod.name,
            style: pfMediumStyle(color: ColorsUtil.title, fontSize: 13.sp),
          ),
        ),
        Text(
          mod.propertion,
          style: pfMediumStyle(color: ColorsUtil.content, fontSize: 13.sp),
        ),
        Expanded(
          child: Container(
            margin: EdgeInsets.only(left: 20.r),
            alignment: Alignment.centerRight,
            child: Text(
              '${mod.count}家',
              textAlign: TextAlign.right,
              style: pfMediumStyle(color: ColorsUtil.title, fontSize: 13.sp),
            ),
          ),
        )
      ],
    ),
  );
}
